package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.NamePageVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.UserPageVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.DropdownItem;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.UserQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.request.CommonIdVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.request.MemberInspectAddVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.request.MemberInspectPageVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.request.MemberInspectUpdateVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.response.MemberInspectPageQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.response.MemberInspectVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.response.SubMemberQueryVO;
import com.ssy.lingxi.member.merchant.service.web.IMemberInspectService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 会员能力 - 会员考察
 * @author yzc
 * @version 2.0.0
 * @date 2021/5/18
 */
@RestController
@RequestMapping("/member/inspect")
public class MemberInspectController {
    @Resource
    private IMemberInspectService memberInspectService;

    /**
     * 获取“考察类型”下拉框条件
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/types", method = RequestMethod.GET)
    public Wrapper<List<DropdownItem>> getPageConditions(@RequestHeader HttpHeaders headers) {
        return memberInspectService.getPageConditions(headers);
    }

    /**
     * “新增会员审查” - 选择下级会员
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/members", method = RequestMethod.GET)
    public Wrapper<PageData<SubMemberQueryVO>> pageSubMembers(@RequestHeader HttpHeaders headers, @Valid NamePageVO pageVO) {
        return memberInspectService.pageSubMembers(headers, pageVO);
    }

    /**
     * “新增或修改会员审查” - 选择用户
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/users", method = RequestMethod.GET)
    public Wrapper<PageData<UserQueryVO>> pageUsers(@RequestHeader HttpHeaders headers, @Valid UserPageVO pageVO) {
        return memberInspectService.pageUsers(headers, pageVO);
    }

    /**
     * 分页查询会员考察
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberInspectPageQueryVO>> pageMemberInspect(@RequestHeader HttpHeaders headers, @Valid MemberInspectPageVO queryVO) {
        return memberInspectService.pageMemberInspect(headers, queryVO);
    }

    /**
     * 新增会员考察
     * @param headers Http头部信息
     * @param addVO 接口参数
     * @return 新增结果
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Wrapper<Void> addMemberInspect(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberInspectAddVO addVO) {
        return memberInspectService.addMemberInspect(headers, addVO);
    }

    /**
     * 查询会员考察详情
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Wrapper<MemberInspectVO> getMemberInspect(@RequestHeader HttpHeaders headers, @Valid CommonIdVO commonIdVO) {
        return memberInspectService.getMemberInspect(headers, commonIdVO);
    }


    /**
     * 修改会员考察修改
     * @param headers Http头部信息
     * @param updateVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberInspect(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberInspectUpdateVO updateVO) {
        return memberInspectService.updateMemberInspect(headers, updateVO);
    }

    /**
     * 删除会员考察
     * @param headers Http头部信息
     * @param commonIdVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> addMemberInspect(@RequestHeader HttpHeaders headers, @RequestBody @Valid CommonIdVO commonIdVO) {
        return memberInspectService.deleteMemberInspect(headers, commonIdVO);
    }

}
